<template>
  <div class="like-page">
    <!-- 下滑到底部自动加载新内容 -->
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <ArticleItem v-for="item in list" :key="item.id" :item="item"></ArticleItem>
    </van-list>
  </div>
</template>

<script>
import { getArticleCollectOrLike } from '@/api/article'

export default {
  name: 'LikePage',
  data () {
    return {
      list: [],
      page: 1,
      pageSize: 10,
      optType: 1,
      loading: false,
      finished: false
    }
  },
  methods: {
    async onLoad () {
      // 异步更新数据
      const { data } = await getArticleCollectOrLike({
        optType: this.optType,
        pageSize: this.pageSize,
        page: this.page
      })
      console.log(data)
      this.list.push(...data.rows)
      this.loading = false
      this.page++
      if (this.page > data.current) {
        this.finished = true
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>
